package com.superboo.utils;

import com.superboo.base.enums.ResultEnum;
import com.superboo.core.domain.Result;

/**
 * ResultUtil
 *
 * @author peiran zhang
 * @date 2017/3/20
 */
public class ResultUtil {

    public static Result success(){
        return success(null);
    }

    public static Result success(Object object){
        Result result = new Result();
        result.setCode(ResultEnum.SUCCESS.getCode());
        result.setMsg(ResultEnum.SUCCESS.getMsg());
        result.setData(object);
        return result;
    }

    public static Result validationError(String message){
        Result result = new Result();
        result.setCode(ResultEnum.VALIDATION_ERROR.getCode());
        result.setMsg(message);
        return result;
    }

    public static Result error(Integer code,String message){
        Result result = new Result();
        result.setCode(code);
        result.setMsg(message);
        return result;
    }
}
